import 'package:flutter/material.dart';
import 'dart:async';

import 'package:aweb5/bean/aplus/common_result_entity.dart';
import 'package:aweb5/bean/aplus/group_plan_list_entity.dart';
import 'package:aweb5/generated/json/common_result_entity_helper.dart';
import 'package:aweb5/generated/json/group_list_entity_helper.dart';
import 'package:aweb5/generated/json/group_plan_list_entity_helper.dart';
import 'package:aweb5/generated/json/has_assist_entity_helper.dart';
import 'package:aweb5/generated/json/task_detail_list_entity_helper.dart';
import 'package:aweb5/providerdata/GroupNoti.dart';
import 'package:flutter/material.dart';
import 'package:aweb5/Para.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:aweb5/custom/dash_painter.dart';
import 'package:aweb5/custom/dashed_rect.dart';
import 'package:expand_widget/expand_widget.dart' as p;
import 'package:configurable_expansion_tile/configurable_expansion_tile.dart';
import 'package:aweb5/custom/bubble_widget.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:bubble/bubble.dart';
//import 'package:fluttertoast/fluttertoast.dart';
import 'package:slide_item/slide_item.dart' as s;
import 'package:aweb5/custom/slide_button_page.dart';
import 'package:photo_view/photo_view.dart';
import 'PhotoViewGalleryScreen.dart';
import 'package:aweb5/util/NaviUtil.dart';

import 'package:aweb5/pages/dash_list.dart';
import 'today_plan_homepage.dart';
import 'package:load/load.dart';
import 'package:aweb5/Constants.dart';
import 'package:aweb5/util/HttpClient.dart';
import 'package:aweb5/util/toast_util.dart';
import 'package:aweb5/config/Config.dart';
import 'package:aweb5/bean/aplus/group_list_entity.dart';
import 'package:aweb5/bean/aplus/task_detail_list_entity.dart';
import 'package:aweb5/style.dart';
import 'package:aweb5/bean/aplus/has_assist_entity.dart';
import 'package:aweb5/pages/unregistry.dart';
import 'package:aweb5/pages/registry_success.dart';
import 'package:aweb5/util/DialogUtil.dart';
import 'package:aweb5/widgetlib/menu_widget.dart';
import 'package:aweb5/pages/choose_mission.dart';
import 'package:provider/provider.dart';
import 'package:aweb5/pages/plan_material.dart';
class TransitPaget extends StatefulWidget {
  @override
  _TransitPagetState createState() => _TransitPagetState();
}

class _TransitPagetState extends State<TransitPaget> {

  BuildContext context;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {requestHasAssist();});

  }

  @override
  Widget build(BuildContext context) {
    this.context = context;
    return Container(

    );
  }

  void requestHasAssist() async {

    DialogUtil.showloadingdialog(context);
    try {
      Map<String, dynamic> map = Map<String, dynamic>();

      map["member_id"] = Constants.memberInfoEntity.data.memberId;

      Map<String, dynamic> map1 = await HttpClient.requestLogin(
          Config.requestApi + 'light/checkMemberAuth',
          data: map);


      HasAssistEntity loginEntity = new HasAssistEntity();

      loginEntity = hasAssistEntityFromJson(loginEntity, map1);

      DialogUtil.pop(context);
      if (loginEntity.code == null || loginEntity.code != 200) {
//        Fluttertoast.showToast(msg: "null");
        Toast.show(msg: loginEntity.msg);

//        NaviUtil.pop(context);
        return;
      }
      if (loginEntity.code == 200) {
//        Toast.show(msg: "创建成功");
//        NaviUtil.pop(this.context);

        if (loginEntity.data == 0) {
          NaviUtil.pushAndRemoveUntil(context, Unregistry());

        } else if (loginEntity.data == 1) {
          NaviUtil.pushAndRemoveUntil(context, PlanMaterial());
        } else if (loginEntity.data == 2) {
          NaviUtil.pushAndRemoveUntil(context, RegistrySuccess());
        }
//        Toast.show(msg: loginEntity.data.toString());
      }
    } catch (e) {
      print(e.toString());
      DialogUtil.pop(context);
    }
  }

}
